<?php

class Application_Form_PrixProduit_GestionTypeProduitForm extends Zend_Form
{
  public function init()
  {
    $db = new Application_Model_TypeProduitTable();
    $liste_type_produit = $db->fetchAll($db->select());

    foreach($liste_type_produit as $type_produit)
      {
	$suppr = new Zend_Form_Element_Checkbox('suppr'.$type_produit['nom_type']);
	$suppr->setLabel($type_produit['nom_type'])
	  ->setValue(false)
	  ->setDecorators(array('ViewHelper','FormErrors','Label','Errors',array('div'.$type_produit['nom_type']=>'HtmlTag', array('tag'=>'div','class' => 'case'))));	 
	$this->addElement($suppr);
      }

    $new_type = new Zend_Form_Element_Text('nomNouveauType');
    $new_type->setLabel('Nouveau type de produit :')
      ->addFilter('StripTags')
      ->addFilter('StringTrim')
      ->setDecorators(array('ViewHelper','FormErrors','Label','Errors',array('div'=>'HtmlTag', array('tag'=>'div','class' => 'case'))));
    $this->addElement($new_type);

    $send = new Zend_Form_Element_Submit('send');
    $send->setAttrib('id','send_button')
      ->setLabel('Enregistrer')
      ->setAttrib('class','button')
      ->setDecorators(array('ViewHelper','FormErrors','Errors')); 
    $this->addElement($send);

    $cancel = new Zend_Form_Element_Reset('cancel');
    $cancel->setAttrib('id','send_button')
      ->setLabel('Annuler')
      ->setAttrib('class','button')
      ->setDecorators(array('ViewHelper','FormErrors','Errors'));
    $this->addElement($cancel); 

    
  }
}
